package com.example.fw;

import org.openqa.selenium.By;
import com.example.tests.ContactData;

public class ContactHelper extends HelperBase {

	public ContactHelper(ApplicationManager manager) {
		super(manager);
	}

	public void initNewContact() {
		click(By.linkText("add new"));
	}

	public void fillContactForm(ContactData contact) {
		type(By.name("firstname"), contact.firstName);
		type(By.name("lastname"), contact.secondName);
		type(By.name("address"), contact.address);
		type(By.name("home"), contact.homePhone);
		type(By.name("mobile"), contact.mobilePhone);
		type(By.name("email"), contact.email);
		type(By.name("email2"), contact.email2);
		selectByText(By.name("bday"), contact.day);
		selectByText(By.name("bmonth"), contact.month);
		type(By.name("byear"), contact.year);
		selectByText(By.name("new_group"), contact.newgroup);
		type(By.name("address2"), contact.address2);	
		type(By.name("phone2"), contact.phone2);
	}


	public void submitContactCreation() {
		click(By.name("submit"));
	}

	public void deleteContact() {
		selectContactByValue();
		click(By.xpath("//input[@value='Delete']"));
	}

	public void selectContactByValue() {
		click(By.xpath("//img[@alt='Edit'][1]"));
	}
		
	public void submitContactModification() {
		click(By.xpath("//input[@value='Update']"));
		
	}

}
